/*
 * @Author: 康家赫 13349195+kangjiahe666@user.noreply.gitee.com
 * @Date: 2024-04-26 17:27:47
 * @LastEditors: 康家赫 13349195+kangjiahe666@user.noreply.gitee.com
 * @LastEditTime: 2024-04-29 13:26:22
 * @FilePath: \MDK-ARMd:\Desktop\mcu_practice\mcu_experience1\kjh_usingcode\controler.c
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include "adc.h"
#include "gpio.h"
#include "main.h"
#include "delay.h"
#include "rocker.h"
#include <stdbool.h> 
#include "controler.h"
#include "beep.h"
#include "OS.h"

extern uint16_t Rocker_Y_Value;
extern uint16_t Rocker_X_Value;
int x = 0;
int y = 0;
int rocker_order_y()
{   
    int i = 0;//重按消抖参数
    if (ADC_Read(ADC_CHANNEL_0) > 2300)//Y轴加
    {
        delay_ms(50);
        if (ADC_Read(ADC_CHANNEL_0) < 4000&&i==0)
        {   
        tips_2(); 
        y++;
        delay_ms(50);
        }
        if (ADC_Read(ADC_CHANNEL_0) >4050)
        {
            tips_1();i=1;
            delay_ms(800);
        }
    } 
                                                                                                                                                                                                                      
    if (ADC_Read(ADC_CHANNEL_0) < 1900)
        {   
            delay_ms(50);
            if (ADC_Read(ADC_CHANNEL_0) < 50)
            {
                tips_1();i=1;
                delay_ms(800);
            }
            if (ADC_Read(ADC_CHANNEL_0) > 250&&i==0) 
            {
            tips_2();
            y--;
            delay_ms(50);
            }
        }
    return y;
}








int rocker_order_x()
{   
    int i = 0;//重按消抖参数
    
if (ADC_Read(ADC_CHANNEL_1) > 2300)
        {   
            delay_ms(50);
            if (ADC_Read(ADC_CHANNEL_1) < 4000&&i==0)
            {
                tips_2();
                x++;
                delay_ms(50);
            }
            if (ADC_Read(ADC_CHANNEL_1) >4050)
            {
            tips_1();i=1;
            delay_ms(800);
            }
        }

        if (ADC_Read(ADC_CHANNEL_1) < 1900)
        {
            delay_ms(50);
            if (ADC_Read(ADC_CHANNEL_1) <50)
            {
                tips_1();i=1;
                delay_ms(800);
            }
            if (ADC_Read(ADC_CHANNEL_1) > 250&&i==0) 
            {
            tips_2();
            x--;
            delay_ms(50); 
            }
        }
        return x;
}
